package com.heima.comment.controller;

import com.heima.comment.dto.CommentDto;
import com.heima.comment.dto.CommentLikeDto;
import com.heima.comment.dto.CommentSaveDto;
import com.heima.comment.entity.ApComment;
import com.heima.comment.service.ICommentService;
import com.heima.comment.vo.ApCommentVo;
import com.heima.common.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("api/v1/comment")
public class CommentController {

    @Autowired
    ICommentService commentService;

    /**
     * 发布评论
     * @param dto
     * @return
     */
    @PostMapping("save")
    public ResponseResult saveComment (@RequestBody CommentSaveDto dto) {
         return commentService.saveComment(dto);
    }

    /**
     * 评论点赞
     * @param dto
     * @return
     */
    @PostMapping("like")
    public ResponseResult like (@RequestBody CommentLikeDto dto) {
        return commentService.like(dto);
    }

    /**
     * 加载文章对应的评论列表
     * @param dto
     * @return
     */
    @PostMapping("load")
    public ResponseResult load (@RequestBody CommentDto dto) {
        return commentService.load(dto);
    }
}
